Function definition:
PowerD makes it possible to use different types of functions. First
function type is normal linked library function which allows LIST
using. All used arguments are loaded into the stack in inverse order
and then the function is called:
LPROC procname(args)(results)
LPROC is mostly used by C compilers, it parses arguments inverted from its definition:
x(a,b,c)
this moves to stack c then, b and then a, if You use a list as a last argument, all list
items will be inserted to stack in same order:
LPROC x(u,v,w:LIST OF LONG)
x(a,b,c,d,e,f)
this moves to stack f, e, d, c, b and a. This is quite dull when you want use something
like this:
LPROC x(a,b,c,d)
n:=0
x(n++,n++,n++,n++)
this will copy to a 3, to b 2, to c 1 and to d 0.
Second is PowerD procedure compatible stack loading. It loads arguments in right order
but don't (currently) allows the LISTs. These are also used for external procedures:
EPROC procname(args)(results)
This is quite more intelligent, but it doesn't allow inline lists as a last argument,
you can of course use normal lists (closed in: []).
EPROC x(a,b,c,d)
n:=0
x(n++,n++,n++,n++)
works correctly, moves 0 to a, 1 to b, 2 to c and 3 to d.
Last one is best suited for assembler routines, which doesn't use stack (it is slower
than registers). Here is the limitation gave by count of registers on the cpu (MC68k
allows 8 data, 5 address registers (don't use a6 and a7) and 8 float registers. PPC
allows about 25 data/address registers and 31 float registers.):
RPROC procname(args with registers)(results)[='asm']
As you can see, it is possible to add an assembler source after RPROC definition, this
way you can generate inlined functions. Be careful about the assembler source you must
adhere right syntax:
- each line starts with tabulator '\t' or some spaces or a label
- each line must be ended with linefeed '\n'
- you must use right instruction set
- it is absolutely not affected by PowerD, it will be only copied instead of the
function call
- it is normal string, so you can use multi line strings